Skip to content

Feat/pgo v3#1138

Open
henderkes wants to merge 34 commits into
v3from
feat/pgo-v3
Open

Feat/pgo v3#1138
henderkes wants to merge 34 commits into
v3from
feat/pgo-v3

Conversation

@henderkes
Copy link
Copy Markdown
Collaborator

What does this PR do?

Checklist before merging

If your PR involves the changes mentioned below and completed the action, please tick the corresponding option.
If a modification is not involved, please skip it directly.

  • If you modified *.php or *.json, run them locally to ensure your changes are valid:
    • composer cs-fix
    • composer analyse
    • composer test
    • bin/spc dev:sort-config
  • If it's an extension or dependency update, please ensure the following:
    • Add your test combination to src/globals/test-extensions.php.
    • If adding new or fixing bugs, add commit message containing extension test or test extensions to trigger full test suite.

@henderkes henderkes marked this pull request as ready for review May 11, 2026 14:49
@henderkes henderkes requested a review from crazywhalecc May 11, 2026 14:49
@crazywhalecc crazywhalecc added the need-test This PR has not been tested yet, cannot merge now label May 12, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

StaticPHP Test Bot

Detected: Extensions: opcache, password_argon2, pgsql, spx | Libraries: bzip2, fastlz, gettext-win, icu, jbig, krb5, liblz4, ncurses, openssl, postgresql, qdbm, unixodbc, watcher | Targets: clang-runtime-bits, curl, php
Active labels: none
Config: Linux x86_64 + Windows x86_64 + macOS arm64 | PHP 8.5 NTS

@henderkes
Copy link
Copy Markdown
Collaborator Author

(I tested with static-php/packages v3 branch, php 8.5 zig on rpm. Tests with Alpine and gcc are still to finish in a few hours when ci runs.)

@henderkes
Copy link
Copy Markdown
Collaborator Author

Wair, why is curl a target like php and not a package/library? We don't compile the exe right?

@crazywhalecc
Copy link
Copy Markdown
Owner

Wair, why is curl a target like php and not a package/library? We don't compile the exe right?

We could compile curl.exe, which shows that StaticPHP is not only suitable for building static PHP, but also for other projects. Just like we already support building pkg-config and re2c. Making them targets simply makes reasonable.

target is superset of library.

@henderkes
Copy link
Copy Markdown
Collaborator Author

Wair, why is curl a target like php and not a package/library? We don't compile the exe right?

We could compile curl.exe, which shows that StaticPHP is not only suitable for building static PHP, but also for other projects. Just like we already support building pkg-config and re2c. Making them targets simply makes reasonable.

target is superset of library.

Okay, added curl.exe on Windows too. Also figured out the root cause of the BUILD_CC patch minilua crash (zigs undefined behaviour sanitizer tripping up, if you run CC="clang -fsanitize=undefined" it will also fail) which coincidentally also fixed a possible edge case bug. BUILD_CC is also used for gen_ir so by using a different vm type it could have theoretically clashed.

@henderkes
Copy link
Copy Markdown
Collaborator Author

Oh, there's even an issue running the binaries despite no undefined sanitizer that I can't reproduce locally or in docker. Very weird.

@crazywhalecc
Copy link
Copy Markdown
Owner

Oh, there's even an issue running the binaries despite no undefined sanitizer that I can't reproduce locally or in docker. Very weird.

Yup. I have no idea except using native compiler instead.

@henderkes
Copy link
Copy Markdown
Collaborator Author

Hmm, the iconv fail on windows should be unrelated to my changes.

{
// get other things
$result = self::execWithResult("pkg-config --static --cflags-only-other {$pkg_config_str}");
$result = self::execWithResult("pkg-config --static --cflags {$pkg_config_str}");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need --cflags here? Output may be redundant.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imagemagick failed because it was missing -I... paths.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this behavior is safe and not tested here, but I'd rather fix ImageMagick than change the entire pkgconfig for a single library.

henderkes added a commit that referenced this pull request May 16, 2026
Comment thread src/Package/Library/watcher.php
{
// get other things
$result = self::execWithResult("pkg-config --static --cflags-only-other {$pkg_config_str}");
$result = self::execWithResult("pkg-config --static --cflags {$pkg_config_str}");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this behavior is safe and not tested here, but I'd rather fix ImageMagick than change the entire pkgconfig for a single library.

Comment thread src/Package/Artifact/zig.php Outdated
public function fixClangRuntimeBits(): bool
{
$installer = new PackageInstaller(interactive: false);
$installer->addInstallPackage('clang-runtime-bits');
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably find a better name for this then 😆

Copy link
Copy Markdown
Owner

@crazywhalecc crazywhalecc May 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any better suggestions? 🧐

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compiler-rtCrtObjects?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Camel case looks weird here. And zig-compiler-rt ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not full compiler-rt, only the crt start and end objects.

compiler-rt-crt-objects?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might also add llvm-objcopy because gnu objcopy is too dumb to work on other arch binaries.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I think we download full compiler rt anyway, just compiler-rt or llvm-compiler-rt is acceptable.

Copy link
Copy Markdown
Collaborator Author

@henderkes henderkes May 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From compiler-rt we only need the crt objects and the profiling runtime library. llvm-objcopy is from llvm-binutils. Different download.

Or we download full prebuilt llvm-toolchain. It has everything we need but it's a 2gb download instead of 200kb+2 min build time.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: downloading compiler-rt is not a good idea because we'd need to download 2gb per target platform, so at least 2x. For llvm-objcopy we could download, but I feel like 2 minutes of build time are preferable to a 2gb download.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need-test This PR has not been tested yet, cannot merge now

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants